#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
	string s, t;
	int maxCost;
	cin>>s>>t>>maxCost;
	int n = s.length();
    vector<int> diff(n, 0);
    for (int i = 0; i < n; i++) {
        diff[i] = abs(s[i] - t[i]);
    }
    int maxLength = 0;
    int start = 0, end = 0;
    int sum = 0;
    while (end < n) {
        sum += diff[end];
        while (sum > maxCost) {
            sum -= diff[start];
            start++;
        }
        maxLength = max(maxLength, end - start + 1);
        end++;
    }
    cout<<maxLength;

	return 0;
} 
